/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.imenu.ejb;

import com.imenu.entity.ImenuCustomer;
import com.imenu.entity.ImenuLang;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Yunzi
 */
@Stateless
public class ImenuCustomerFacade extends AbstractFacade<ImenuCustomer> {

    @PersistenceContext(unitName = "iMenuPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public ImenuCustomerFacade() {
        super(ImenuCustomer.class);
    }

    public ImenuCustomer findByDeviceId(String deviceId) {
        try {
            return (ImenuCustomer) getEntityManager().createNamedQuery("ImenuCustomer.findByDeviceId").setParameter("deviceId", deviceId).getSingleResult();
        } catch (Exception e) {
            return null;
        }
    }
}
